package com.bileetacrm;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class BileetaAddNewEvent extends Activity {
	Button btnstartdate,btnduedate;
	String OptionKey;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.bileeta_add_new_event);

		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			OptionKey = extras.getString("TAGID");
		} else {
			OptionKey = "0";
		}
		
		
		btnstartdate = (Button) findViewById(R.id.btnstartdate);
		btnduedate = (Button) findViewById(R.id.btnduedate);
		
		btnstartdate.setText(getAddDateTimeString().toString()); 
		btnduedate.setText(getAddDateTimeString().toString());
		
		/********** Android Drawer Menu Action ****************/
		Button buttonAddInquiry = (Button) findViewById(R.id.menu_add_inquiry);
		buttonAddInquiry.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent myIntent = new Intent(BileetaAddNewEvent.this,
						BileetaAddNewInquery.class);
				myIntent.putExtra("TAGID", OptionKey);
				startActivityForResult(myIntent, 0);

			}
		});

		Button buttonAddEvent = (Button) findViewById(R.id.menu_add_event);
		buttonAddEvent.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent myIntent = new Intent(BileetaAddNewEvent.this,
						BileetaAddNewEvent.class);
				myIntent.putExtra("TAGID", OptionKey);
				startActivityForResult(myIntent, 0);

			}
		});

		Button buttonAddtionalInfo = (Button) findViewById(R.id.menu_additional_info);
		buttonAddtionalInfo.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent myIntent = new Intent(BileetaAddNewEvent.this,
						BileetaAddLeadAdditionalInfo.class);
				myIntent.putExtra("TAGID", OptionKey);
				startActivityForResult(myIntent, 0);

			}
		});

		Button buttonAddContact = (Button) findViewById(R.id.menu_add_to_contacts);
		buttonAddContact.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent myIntent = new Intent(BileetaAddNewEvent.this,
						BileetaAddContactInformation.class);
				myIntent.putExtra("TAGID", OptionKey);
				startActivityForResult(myIntent, 0);

			}
		});
		
		Button displayDetailsView = (Button) findViewById(R.id.displayDetailsView);
		displayDetailsView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if(OptionKey.equals("24")){
					Intent intent = new Intent(BileetaAddNewEvent.this,BileetaSalesInquirySummaryActivity.class);
					startActivity(intent);
				}else{
					Intent intent = new Intent(BileetaAddNewEvent.this,BileetaFragmentActivity.class);
					intent.putExtra("TAGID", "1");
					startActivity(intent);
				}
			}
		});
		/**********************************************************/
	}
	
	
	private String getAddDateTimeString() {
		Calendar cad = Calendar.getInstance();
		SimpleDateFormat dfad = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
		String formattedAddDate = dfad.format(cad.getTime());
		return formattedAddDate;
	}
	@Override
	public void onBackPressed()
	{
		if(OptionKey.equals("24")){
			Intent intent = new Intent(BileetaAddNewEvent.this,BileetaSalesInquirySummaryActivity.class);
			startActivity(intent);
		}else{
			Intent intent = new Intent(BileetaAddNewEvent.this,BileetaFragmentActivity.class);
			intent.putExtra("TAGID", "1");
			startActivity(intent);
		}
	     // code here to show dialog
	     super.onBackPressed();  // optional depending on your needs
	}
}
